<template>
		<view >
		    <view  >
		        <view class='header'>
		            <image src='../../static/img/wx_login.png'></image>
		        </view>
		
		        <view class='content'>
		            <view>申请获取以下权限</view>
		            <text>获得你的公开信息(昵称，头像等)</text>
		        </view>
		
		         <button class='bottom' @click="getLogin()"> 授权登录</button>
		           
		    </view>
		    <!-- <view wx:else>请升级微信版本</view> -->
		</view>
</template>

<script>
	import config from '@/config/index.config.js'
	export default {
		data() {
			return {
			}
		},
		methods:{
			getLogin(){
				var loginCode;
				// uni.login({
				// 	success: (res2) => {
				// 		console.log(res2)
				// 		loginCode = res2.code;
				// 	}
				// })
				// uni.getUserProfile({
				// 	desc: '用于完善会员资料',
				// 	success: (res3) => {
				// 		console.log(res3);
				// 		var authInfo = res3;
						var data = {
							// code: loginCode,
							// iv: authInfo.iv,
							// rawData: authInfo.rawData,
							// signature: authInfo.signature,
							// encryptedData: authInfo.encryptedData,
							// regcode: uni.getStorageSync('regcode') || ''
						}
						uni.request({
							url: config.baseUrl + '/member/login/wxapp_login',
							data: data,
							method: 'POST',
							success(res) {
								if (res.statusCode == 200) {
									uni.setStorageSync('hhToken', res.data.data.token.access_token);
									if (res.data.code == 100) {
										uni.removeStorageSync('regcode')
										uni.redirectTo({
											url: '/pages/public/bandPhone'
										})
									}else{
										uni.switchTab({
											url: `/pages/index/index`
										})
									}
								}
							}
						})
				// 	},
				// 	fail: (res) => {
				// 		console.log(res)
				// 	}
				// });
			}
		}
	}

</script>

<style scoped>
	
.header {
    margin: 90rpx 0 90rpx 50rpx;
    border-bottom: 1px solid #ccc;
    text-align: center;
    width: 650rpx;
    height: 300rpx;
    line-height: 450rpx;
}

.header image {
    width: 200rpx;
    height: 200rpx;
}

.content {
    margin-left: 50rpx;
    margin-bottom: 90rpx;
}

.content text {
    display: block;
    color: #9d9d9d;
    margin-top: 40rpx;
}

.bottom {
    border-radius: 80rpx;
    margin: 70rpx 50rpx;
    font-size: 35rpx;
    background-color: #1aad19;
    color: #fff;
    border: none;
    outline: none;
}

</style>
